// 校验规则
function Rule(object) {
  var obj = object
  const tipMsg = '不能为空'

  this.setEffDateRules = function() {
    obj.rules.effDate = [
      { required: true, message: tipMsg, trigger: 'blur' },
      { required: true, message: tipMsg, trigger: 'change' },
      { validator: obj.validate.effDateCheck, trigger: 'blur' },
      { validator: obj.validate.effDateCheck, trigger: 'change' }
    ]
  }

  this.setOperationEndDateRules = function() {
    obj.rules.operationEndDate = [
      { required: true, message: tipMsg, trigger: 'blur' },
      { required: true, message: tipMsg, trigger: 'change' },
      { validator: obj.validate.operationEndDateCheck, trigger: 'blur' },
      { validator: obj.validate.operationEndDateCheck, trigger: 'change' }
    ]
  }

  this.setScheduleSubjectRules = function() {
    obj.rules.scheduleSubject = [{ required: true, message: tipMsg, trigger: 'blur' }, { required: true, message: tipMsg, trigger: 'change' }]
  }

  this.setScheduleTypeRules = function() {
    obj.rules.scheduleType = [{ required: true, message: tipMsg, trigger: 'blur' }, { required: true, message: tipMsg, trigger: 'change' }]
  }

  this.setcateScopeRules = function() {
    obj.rules.cateScope = [{ required: true, message: tipMsg, trigger: 'blur' }, { required: true, message: tipMsg, trigger: 'change' }]
  }

  this.setScheduleGroupRules = function() {
    obj.rules.scheduleGroup = [{ required: true, message: tipMsg, trigger: 'blur' }, { required: true, message: tipMsg, trigger: 'change' }]
  }

  // 初始化校验规则
  this.initRules = function() {
    for (var key in this) {
      // console.log(key)
      if (key === 'initRules') {
        continue
      }
      if (typeof (this[key]) === 'function') {
        this[key]()
      }
    }
  }
}
export default Rule
